*=$0801
; 2018 SYS 2062
 !word main-2, 10 
 !byte $9e
 !text " 2062"
 !byte $00,$00,$00
 
main

      ;clear screen
      lda #147
      jsr $ffd2

        sei
  ;sprite pointers
        ldx #7
        lda #$ff
sprp    sta $07f8,x
        dex
        bpl sprp

        ;sprite data
        ldx #63
sprd    lda spribits,x
        sta $3fc0,x
        dex
        bpl sprd

;colors and initital sprite x positions        
        ldx #7
        ldy #14
sprpc   txa
        clc
        adc #7
        sta $d027,x
        tya
        asl
        asl
        asl
        adc #100
        sta $d000,y
        dey
        dey
        dex
        bpl sprpc

        ;Turn on sprites
        lda #$ff
        sta $d015

        sei
        ;wait for line 10
loop    lda #10
loopb   cmp $d012
        bne loopb
        
        ;Place sprites in the top of the screen
        ldy #14
        lda #80
vpos1   sta $d001,y
        dey
        dey
        bpl vpos1

        ;wait for line 128
        lda #128
loopmb  cmp $d012
        bne loopmb
        
        ;Place sprites in the bottom of the screen
        ldy #14
        lda #180
vpos2   sta $d001,y
        dey
        dey
        bpl vpos2
        jmp loop        
        

spribits
  !byte 0,127,0,1,255,192,3,255,224,3,231,224
  !byte 7,217,240,7,223,240,7,217,240,3,231,224
  !byte 3,255,224,3,255,224,2,255,160,1,127,64
  !byte 1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
  !byte  0,62,0,0,62,0,0,62,0,0,28,0 
        

